#!/bin/sh
#根据进程名杀死进程，例如 sh xxxx.sh redis
# echo [ $# -lt 1 ]

PARAMS=$#
echo $PARAMS

if [ $# -lt 1 ]
then
  echo "缺少参数：procedure_name"
  exit 1
fi
 
PROCESS=`ps -ef|grep $1|grep -v grep|grep -v PPID|awk '{ print $2}'`
for i in $PROCESS
do
  echo "kill the $1 process [ $i ]"
  kill -9 $i
done

# 如果觉得上边的代码忒复杂，可以直接使用下面的一句来实现
# ps -ef | grep procedure_name | grep -v grep | awk '{print $2}' | xargs kill -9
# ps -ef | grep 7001 | grep -v grep | awk '{print $2}' | xargs kill -9
# ps -eo "pid,command" | grep -- "--title=egg-server-deep_foundation"